<template>
  <div class="reportFormPage">
    <div id="domid" class="report-dom">
      <el-row>
        <el-col :span="5" :offset="19">
          <div class="pageNumBox">
            <span>第</span>
            <span class="placeholder-min text-center">&nbsp;{{ form.page }}&nbsp;</span>
            <span>页，共</span>
            <span class="placeholder-min text-center">&nbsp;{{ form.totalPage }}&nbsp;</span>
            <span>页</span>
          </div>
        </el-col>
      </el-row>
      <div class="topTwoBox">
        <div class="centerName">水泥混凝土抗弯拉强度试验检测记录表</div>
        <div class="codeText">
          <tr>
            BGLQ05002F
          </tr>
        </div>
      </div>
      <div class="threeTopBox">
        <div class="left-border">
          <div class="box-title">检测单位名称：</div>
          <div class>{{ form.jiancdwmc }}</div>
        </div>
        <div class="right-border">
          <span>记录编号：</span>
          <span class="placeholder">{{ form.jilbh }}</span>
        </div>
      </div>
      <!-- .........................1111111111111111111111111111111......................................................... -->
      <div class="table-border">
        <table height="220px" class="top-table">
          <tbody>
            <tr>
              <td align="center" width="15%" height="25">
                <span style="width: 90px; display: inline-block">工程名称</span>
              </td>
              <td width="85%" class="text-center" colspan="3">
                <span>{{ form.gongcmc }}</span>
              </td>
            </tr>
            <tr>
              <td align="center" width="15%" height="25">
                <span style="width: 90px; display: inline-block">工程部位/用途</span>
              </td>
              <td width="85%" class="text-center" colspan="3">
                <span>{{ form.gongcbwyt }}</span>
              </td>
            </tr>
            <tr>
              <td height="50" align="center">样品信息</td>
              <td class="specimen-border" colspan="3">
                <span>样品名称：</span>
                <span :class="{ placeholder: !form.yangpmc }">{{ form.yangpmc }}</span>
                <span>；样品编号：</span>
                <span :class="{ 'placeholder-long': !form.yangpbh }">{{ form.yangpbh }}</span>
                <span>；样品数量：</span>
                <span :class="{ placeholder: !form.yangpsl }">{{ form.yangpsl }}</span>
                <span>；样品状态：</span>
                <span :class="{ placeholder: !form.yangpzt }">{{ form.yangpzt }}</span>
                <!--                <span>；来样时间：</span>-->
                <!--                <span :class="{ 'placeholder':!form.yangpsj }">{{ form.yangpsj }}</span>-->
              </td>
            </tr>
            <tr>
              <td height="25" align="center" width="15%">
                <span style="width: 90px; display: inline-block">试验检测日期</span>
              </td>
              <!-- <td width="35%" class="text-center">{{ form.shiyjcrq }}</td> -->
              <td width="35%" class="text-center">
                <el-input v-model="form.shiyjcrq" />
              </td>

              <td align="center" style="width: 15%">
                <span style="width: 90px; display: inline-block">试验条件</span>
              </td>
              <td v-if="isPdf" width="35%">
                温度：
                <span style="display: inline-block; width: 10%">{{ form.wend }}</span>
                ℃；湿度：
                <span style="display: inline-block; width: 10%">{{ form.xiangdsd }}</span
                >%RH
              </td>
              <td v-else width="35%">
                温度：
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.wend" class="height100" style="width: 15%" />℃；湿度：
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.xiangdsd" class="height100" style="width: 15%" />%RH
              </td>
            </tr>
            <tr>
              <td height="50" align="center" width="15%">
                <span style="width: 90px; display: inline-block">检测依据</span>
              </td>
              <td width="35%">
                <span v-if="isPdf">{{ form.jiancyj }}</span>
                <el-input v-else type="textarea" v-model="form.jiancyj" :rows="2" class="mark" @dblclick.native="showBsJiancyjView" readonly />
              </td>
              <td align="center" width="15%">
                <span style="width: 90px; display: inline-block">判定依据</span>
              </td>
              <td width="35%">
                <span v-if="isPdf">{{ form.pandyj }}</span>
                <el-input v-else type="textarea" v-model="form.pandyj" :rows="2" @dblclick.native="showBsJudgeBaseView" @focus="handleFocus('pandyj')" class="mark" />
              </td>
            </tr>
            <tr class="bottom-border">
              <td height="50" align="center">
                <div>主要仪器设备</div>
                <div>名称及编号</div>
              </td>
              <td colspan="3">
                <span v-if="isPdf">{{ form.zhuyyqsbmcjbh }}</span>
                <el-input v-else type="textarea" :rows="2" v-model="form.zhuyyqsbmcjbh" class="height100 width100 mark" @dblclick.native="showBsInstrumentView" readonly></el-input>
              </td>
            </tr>
          </tbody>
        </table>
        <!-- .................................22222222222222222222222222222222............................................... -->
        <table height="616px" class="middle-table">
          <tbody>
            <tr trindex="0" width="100%">
              <td width="15%" colspan="2" height="30">设计强度等级</td>
              <td colspan="3" height="30">
                <el-select clearable  v-model="form.shejqddj" placeholder @change="qddjChange()" class="hide-icon width100 height100">
                  <el-option v-for="item in qddjList" :key="item.syYjName" :label="item.syYjName" :value="item.syYjName" />
                </el-select>
              </td>
              <td width="15%" colspan="2" height="30">拌合方式</td>
              <td width="22%" colspan="2" height="30">
                <el-input v-model="form.banhfs" @blur="passValue" @keydown.native="handleKeyDown($event, 0, 0)" :ref="'0_0'" />
              </td>
              <td colspan="2" height="30">支座间距(mm)</td>
              <td colspan="2" height="30">
                <el-input v-model="form.zhizjj" type="Number" @blur="changeZhizjj" @keydown.native="handleKeyDown($event, 0, 1)" :ref="'0_1'" />
              </td>
            </tr>

            <tr trindex="1">
              <td colspan="2" height="30">成型方法</td>
              <td colspan="3" height="30">
                <el-input v-model="form.chengxff" @blur="passValue" @keydown.native="handleKeyDown($event, 1, 0)" :ref="'1_0'" />
              </td>
              <td colspan="2" height="30">养护方法</td>
              <td colspan="2" height="30">
                <el-input v-model="form.yanghff" @blur="passValue" @keydown.native="handleKeyDown($event, 1, 1)" :ref="'1_1'" />
              </td>
              <td colspan="2" height="30">坍落度(mm)</td>
              <td colspan="2" height="30">
                <el-input v-model="form.tanld" type="Number" @blur="passValue" @keydown.native="handleKeyDown($event, 1, 2)" :ref="'1_2'" />
              </td>
            </tr>
            <tr trindex="2" width="100%">
              <td colspan="1" rowspan="2">试件编号</td>
              <td colspan="2" rowspan="2" width="15%">制件日期</td>
              <td colspan="2" rowspan="2" width="15%">试验日期</td>
              <td rowspan="2" width="7%">龄期(天)</td>
              <td colspan="2" rowspan="2" width="15%">试件尺寸</td>
              <td rowspan="2" width="8%">破坏荷载(kN)</td>
              <td colspan="2">抗弯拉强度(MPa)</td>
              <td colspan="2" rowspan="2" width="15%">占设计强度百分率(%)</td>
            </tr>
            <tr trindex="3" width="100%">
              <td height="30" width="7%">单值</td>
              <td height="30" width="7%">平均</td>
            </tr>

            <tr trindex="0" width="100%" v-for="(e, index) in list" :key="index">
              <!-- <td>{{ handleshijbh(index + 1, e) }}</td> -->
              <td><el-input v-model="e.shijbh" /></td>
              <td colspan="2" rowspan="3" v-if="(index + 3) % 3 == 0">
                <el-date-picker class="hide-icon" value-format="yyyy-MM-dd" format="yyyy-MM-dd" style="width: 100%" @change="changesyrq(e)" v-model="e.zhizrq" />
              </td>
              <td colspan="2" rowspan="3" v-if="(index + 3) % 3 == 0" width="23%">
                {{ e.shiyrq }}
              </td>
              <td rowspan="3" v-if="(index + 3) % 3 == 0">
                <el-select clearable placeholder v-model="e.lingq" class="hide-icon height100" @change="changesyrq(e)">
                  <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"> </el-option>
                </el-select>
              </td>
              <td colspan="2" rowspan="3" v-if="(index + 3) % 3 == 0">
                <el-select clearable placeholder v-model="e.shijcc" class="hide-icon height100" @change="changeshijcc(e, index)">
                  <el-option v-for="item in shijccList" :key="item.value" :label="item.label" :value="item.value"> </el-option>
                </el-select>
              </td>
              <td>
                <!-- {{ `${index + 2}_0` }} -->
                <el-input type="Number" v-model="e.pohhz" @blur="computeKwlqd(e, index)" @keydown.native="handleKeyDown($event, index + 2, 0)" :ref="`${index + 2}_0`" />
              </td>
              <td>{{ e.kangwlqddz }}</td>
              <td rowspan="3" v-if="(index + 3) % 3 == 0">{{ e.kangwlqdpj }}</td>
              <td colspan="2" rowspan="3" v-if="(index + 3) % 3 == 0" width="15%">{{ e.zhansjqdbfb }}</td>
            </tr>
          </tbody>
        </table>
        <!-- .....................................................33333333333333333................................................... -->
        <table height="30px" class="bottom-table">
          <tr>
            <td>
              <el-input type="textarea" :rows="2" v-model="fjsm" @focus="handleFocus('fujsm')" />
            </td>
          </tr>
        </table>
      </div>
      <!-- .................................44444444444............................................. -->
      <table height="22px" class="transparent">
        <tbody>
          <tr>
            <td width="10%" align="right">检测：</td>
            <td width="15%" align="left"></td>
            <td width="10%" align="right">记录：</td>
            <td width="15%" align="left"></td>
            <td width="10%" align="right">复核：</td>
            <td align="left" width="15%"></td>
            <td width="10%">日期：</td>
            <td align="left" width="15%">
              <div style="display: inline-block; margin-left: 20px">年</div>
              <div style="display: inline-block; margin-left: 20px">月</div>
              <div style="display: inline-block; margin-left: 20px">日</div>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
    <bs-jiancyj-view ref="bsJiancyjViewRef" @select="selectJiancyj" :syType="syType"></bs-jiancyj-view>
    <bs-instrument-view ref="bsInstrumentViewRef" @select="selectInstrument"></bs-instrument-view>
    <bs-judge-base-view ref="bsJudgeBaseViewRef" @select="selectJudge" :syType="syType" />
    <bs-judge-base-edit-view ref="bsJudgeBaseEditViewRef" @submit="selectJudgeBaseEdit" :syType="syType" />
  </div>
</template>

<script>
import { getSnhntKwlqdBsInfo } from "@/api/reportsnhnt/snhntKwlqdBsInfo";

import decimal from "@/utils/big-decimal";
import BsInstrumentView from "@/views/dept/bsInstrument/BsInstrumentView.vue";
import BsJiancyjView from "@/views/sycs/bsJiancyj/BsJiancyjView.vue";
import { computeBiQualification } from "@/api/sycs/biQualification";
import { emptyConvert, handleFocus, handleKeyDown } from "@/views/reportForms/utils";
import BsJudgeBaseView from "@/views/sycs/bsJudgeBase/BsJudgeBaseView.vue";
import BsJudgeBaseEditView from "@/views/sycs/bsJudgeBase/BsJudgeBaseEditView.vue";
import { getQddj } from "@/api/reportsj/sjKyqdBsInfo";
import Bus from "@/utils/bus";
export default {
  name: "bhw",
  components: {
    BsInstrumentView,
    BsJiancyjView,
    BsJudgeBaseView,
    BsJudgeBaseEditView
  },
  data() {
    return {
      huansxs: 1,
      lingq: undefined,
      qddjList: [],
      shijccList: [
        { value: "150x150x550", label: "150x150x550" },
        { value: "100x100x400", label: "100x100x400" }
      ],
      list: [
        { index: 1, shijbh: "", quybw: "", zhizrq: "", shiyrq: "", pohhz: "", kangyqdcz: "", pingjkyqd: "", zhansjqdbfl: "", huansxs: 1 },
        { index: 2, shijbh: "", quybw: "", zhizrq: "", shiyrq: "", pohhz: "", kangyqdcz: "", pingjkyqd: "", zhansjqdbfl: "", huansxs: 1 },
        { index: 3, shijbh: "", quybw: "", zhizrq: "", shiyrq: "", pohhz: "", kangyqdcz: "", pingjkyqd: "", zhansjqdbfl: "", huansxs: 1 },
        { index: 4, shijbh: "", quybw: "", zhizrq: "", shiyrq: "", pohhz: "", kangyqdcz: "", pingjkyqd: "", zhansjqdbfl: "", huansxs: 1 },
        { index: 5, shijbh: "", quybw: "", zhizrq: "", shiyrq: "", pohhz: "", kangyqdcz: "", pingjkyqd: "", zhansjqdbfl: "", huansxs: 1 },
        { index: 6, shijbh: "", quybw: "", zhizrq: "", shiyrq: "", pohhz: "", kangyqdcz: "", pingjkyqd: "", zhansjqdbfl: "", huansxs: 1 },
        { index: 7, shijbh: "", quybw: "", zhizrq: "", shiyrq: "", pohhz: "", kangyqdcz: "", pingjkyqd: "", zhansjqdbfl: "", huansxs: 1 },
        { index: 8, shijbh: "", quybw: "", zhizrq: "", shiyrq: "", pohhz: "", kangyqdcz: "", pingjkyqd: "", zhansjqdbfl: "", huansxs: 1 },
        { index: 9, shijbh: "", quybw: "", zhizrq: "", shiyrq: "", pohhz: "", kangyqdcz: "", pingjkyqd: "", zhansjqdbfl: "", huansxs: 1 },
        { index: 10, shijbh: "", quybw: "", zhizrq: "", shiyrq: "", pohhz: "", kangyqdcz: "", pingjkyqd: "", zhansjqdbfl: "", huansxs: 1 },
        { index: 11, shijbh: "", quybw: "", zhizrq: "", shiyrq: "", pohhz: "", kangyqdcz: "", pingjkyqd: "", zhansjqdbfl: "", huansxs: 1 },
        { index: 12, shijbh: "", quybw: "", zhizrq: "", shiyrq: "", pohhz: "", kangyqdcz: "", pingjkyqd: "", zhansjqdbfl: "", huansxs: 1 },
        { index: 13, shijbh: "", quybw: "", zhizrq: "", shiyrq: "", pohhz: "", kangyqdcz: "", pingjkyqd: "", zhansjqdbfl: "", huansxs: 1 },
        { index: 14, shijbh: "", quybw: "", zhizrq: "", shiyrq: "", pohhz: "", kangyqdcz: "", pingjkyqd: "", zhansjqdbfl: "", huansxs: 1 },
        { index: 15, shijbh: "", quybw: "", zhizrq: "", shiyrq: "", pohhz: "", kangyqdcz: "", pingjkyqd: "", zhansjqdbfl: "", huansxs: 1 },
        { index: 16, shijbh: "", quybw: "", zhizrq: "", shiyrq: "", pohhz: "", kangyqdcz: "", pingjkyqd: "", zhansjqdbfl: "", huansxs: 1 },
        { index: 17, shijbh: "", quybw: "", zhizrq: "", shiyrq: "", pohhz: "", kangyqdcz: "", pingjkyqd: "", zhansjqdbfl: "", huansxs: 1 },
        { index: 18, shijbh: "", quybw: "", zhizrq: "", shiyrq: "", pohhz: "", kangyqdcz: "", pingjkyqd: "", zhansjqdbfl: "", huansxs: 1 }
      ],
      quybw: null,
      huansxsoption: [
        { value: 1, label: "1" },
        { value: 1.35, label: "1.35" }
      ],
      options: [
        { value: 3, label: "3" },
        { value: 7, label: "7" },
        { value: 28, label: "28" }
      ],
      jilbh: "",
      form: {
        shiyrq: "2024年03月09日",
        gongcbwyt: "",
        baogbh: "",
        jiancdwmc: "山东路桥集团试验检测中心有限公司泰安高速公路施工总承包项目工地试验室",
        totalPage: "",
        page: "",
        jiancyj: "",
        zhuyyqsbmcjbh: "",
        gongcmc: "汾阳至石楼高速公路",
        yangpmc: "K39+820-K40+440原地面",
        yangpbh: "JTG/T 3610-2019",
        laiysj: "2022年03月09日",
        yangpsl: "3kg",
        yangpzt: "完好无损"
      },
      twoTableData: {},
      threeTableData: {},
      fjsm: "附加声明：",
      dateText: "2024年05月10日",
      readonly: false
    };
  },
  props: {
    excelId: {
      type: [String, Number],
      default: () => ""
    },
    isPdf: {
      type: Boolean,
      default: () => false
    },
    syType: {
      type: [String, Number],
      default: () => ""
    }
  },
  watch: {},
  created() {
    this.getInfo();
    this.getQddj();
  },
  methods: {
    // 获取详情
    getInfo() {
      // if (!this.excelId) {
      //   return;
      // }

      getSnhntKwlqdBsInfo(this.excelId || this.$defaultExcelId).then((response) => {
        this.form = response.data;
        if (this.form.detailList) {
          this.list = this.form.detailList;
          this.huansxs = this.list[0].huansxs || 1;
        }
      });
    },
    submitForm() {
      for (let i = 0; i < 12; i++) {
        let item = this.list[i];
        if (i <= 9 && (i + 3) % 3 == 0) {
          this.list[i + 1].shijcc = this.list[i + 2].shijcc = item.shijcc;
          this.list[i + 1].zhijrq = this.list[i + 2].zhijrq = item.zhijrq;
          this.list[i + 1].pingjkyqd = this.list[i + 2].pingjkyqd = item.pingjkyqd;
          this.list[i + 1].zhansjqdbfl = this.list[i + 2].zhansjqdbfl = item.zhansjqdbfl;
          this.list[i + 1].lingq = this.list[i + 2].lingq = item.lingq;
          this.list[i + 1].shiyrq = this.list[i + 2].shiyrq = item.shiyrq;
        }
        if (item.pohhz == "") {
          item.pohhz = null;
        }
      }
      return this.form;
    },
    //查询砂浆强度等级列表；
    getQddj() {
      getQddj("水泥混凝土强度等级").then((res) => {
        if (res.data) {
          res.data.forEach((e) => {
            if (!e.syYjName.includes("C")) {
              this.qddjList.push(e);
            }
          });
        }
      });
    },
    //设计强度等级变化
    qddjChange() {
      this.passValue();
      for (let i = 0; i < this.form.detailList.length; i++) {
        this.computeKwlqd(this.form.detailList[i], i);
      }
    },

    //支座间距改变
    changeZhizjj() {
      //  给form传值；
      this.passValue();
      //重新计算抗弯拉强度
      for (let i = 0; i < this.form.detailList.length; i++) {
        this.computeKwlqd(this.form.detailList[i], i);
      }
    },
    //给报告传值；
    passValue() {
      Bus.$emit("setkwlqdbgform", this.form);
    },
    //切换试件尺寸
    changeshijcc(item, i) {
      //设置第2、3条数据试件尺寸
      this.form.detailList[i + 1].shijcc = this.form.detailList[i + 2].shijcc = item.shijcc;
      //重新计算强度
      for (let i = 0; i < this.form.detailList.length; i++) {
        this.computeKwlqd(this.form.detailList[i], i);
      }
    },
    //计算抗弯拉强度；
    computeKwlqd(item, i) {
      if (item.shijcc && this.form.zhizjj && item.pohhz) {
        item.kangwlqddz = this.getkwlqd(item.pohhz, item.shijcc, parseFloat(this.form.zhizjj));
      } else {
        item.kangwlqddz;
      }
      //计算平均抗弯拉强度,占比，结果判定；
      if (i == 0 || i == 1 || i == 2) {
        if (this.form.detailList[0].kangwlqddz && this.form.detailList[1].kangwlqddz && this.form.detailList[2].kangwlqddz) {
          this.form.detailList[0].kangwlqdpj =
            this.form.detailList[1].kangwlqdpj =
            this.form.detailList[2].kangwlqdpj =
              decimal.divide(decimal.add(decimal.add(this.form.detailList[0].kangwlqddz, this.form.detailList[1].kangwlqddz, 9), this.form.detailList[2].kangwlqddz, 9), 3, 2);
          //占比计算
          if (this.form.shejqddj) {
            this.form.detailList[0].zhansjqdbfb =
              this.form.detailList[1].zhansjqdbfb =
              this.form.detailList[2].zhansjqdbfb =
                decimal.divide(decimal.multiply(100, this.form.detailList[0].kangwlqdpj, 9), this.form.shejqddj, 1);
            //结果判定
            if (parseFloat(this.form.shejqddj) <= parseFloat(this.form.detailList[0].kangwlqdpj)) {
              this.form.detailList[0].jiegpd = this.form.detailList[1].jiegpd = this.form.detailList[2].jiegpd = "符合";
            } else {
              this.form.detailList[0].jiegpd = this.form.detailList[1].jiegpd = this.form.detailList[2].jiegpd = "不符合";
            }
          } else {
            this.form.detailList[0].zhansjqdbfb = this.form.detailList[1].zhansjqdbfb = this.form.detailList[2].zhansjqdbfb = null;
            this.form.detailList[0].jiegpd = this.form.detailList[1].jiegpd = this.form.detailList[2].jiegpd = null;
          }
        } else {
          this.form.detailList[0].kangwlqdpj = this.form.detailList[1].kangwlqdpj = this.form.detailList[2].kangwlqdpj = null;
          this.form.detailList[0].zhansjqdbfb = this.form.detailList[1].zhansjqdbfb = this.form.detailList[2].zhansjqdbfb = null;
          this.form.detailList[0].jiegpd = this.form.detailList[1].jiegpd = this.form.detailList[2].jiegpd = null;
        }
      } else if (i == 3 || i == 4 || i == 5) {
        if (this.form.detailList[3].kangwlqddz && this.form.detailList[4].kangwlqddz && this.form.detailList[5].kangwlqddz) {
          this.form.detailList[3].kangwlqdpj =
            this.form.detailList[4].kangwlqdpj =
            this.form.detailList[5].kangwlqdpj =
              decimal.divide(decimal.add(decimal.add(this.form.detailList[3].kangwlqddz, this.form.detailList[4].kangwlqddz, 9), this.form.detailList[5].kangwlqddz, 9), 3, 2);
          //占比计算
          if (this.form.shejqddj) {
            this.form.detailList[3].zhansjqdbfb =
              this.form.detailList[4].zhansjqdbfb =
              this.form.detailList[5].zhansjqdbfb =
                decimal.divide(decimal.multiply(100, this.form.detailList[3].kangwlqdpj, 9), this.form.shejqddj, 1);
            //结果判定
            if (parseFloat(this.form.shejqddj) <= parseFloat(this.form.detailList[3].kangwlqdpj)) {
              this.form.detailList[3].jiegpd = this.form.detailList[4].jiegpd = this.form.detailList[5].jiegpd = "符合";
            } else {
              this.form.detailList[3].jiegpd = this.form.detailList[4].jiegpd = this.form.detailList[5].jiegpd = "不符合";
            }
          } else {
            this.form.detailList[3].zhansjqdbfb = this.form.detailList[4].zhansjqdbfb = this.form.detailList[5].zhansjqdbfb = null;
            this.form.detailList[3].jiegpd = this.form.detailList[4].jiegpd = this.form.detailList[5].jiegpd = null;
          }
        } else {
          this.form.detailList[3].kangwlqdpj = this.form.detailList[4].kangwlqdpj = this.form.detailList[5].kangwlqdpj = null;
          this.form.detailList[3].zhansjqdbfb = this.form.detailList[4].zhansjqdbfb = this.form.detailList[5].zhansjqdbfb = null;
          this.form.detailList[3].jiegpd = this.form.detailList[4].jiegpd = this.form.detailList[5].jiegpd = null;
        }
      } else if (i == 6 || i == 7 || i == 8) {
        if (this.form.detailList[6].kangwlqddz && this.form.detailList[7].kangwlqddz && this.form.detailList[8].kangwlqddz) {
          this.form.detailList[6].kangwlqdpj =
            this.form.detailList[7].kangwlqdpj =
            this.form.detailList[8].kangwlqdpj =
              decimal.divide(decimal.add(decimal.add(this.form.detailList[6].kangwlqddz, this.form.detailList[7].kangwlqddz, 9), this.form.detailList[8].kangwlqddz, 9), 3, 2);
          //占比计算
          if (this.form.shejqddj) {
            this.form.detailList[6].zhansjqdbfb =
              this.form.detailList[7].zhansjqdbfb =
              this.form.detailList[8].zhansjqdbfb =
                decimal.divide(decimal.multiply(100, this.form.detailList[6].kangwlqdpj, 9), this.form.shejqddj, 1);
            //结果判定
            if (parseFloat(this.form.shejqddj) <= parseFloat(this.form.detailList[6].kangwlqdpj)) {
              this.form.detailList[6].jiegpd = this.form.detailList[7].jiegpd = this.form.detailList[8].jiegpd = "符合";
            } else {
              this.form.detailList[6].jiegpd = this.form.detailList[7].jiegpd = this.form.detailList[8].jiegpd = "不符合";
            }
          } else {
            this.form.detailList[6].zhansjqdbfb = this.form.detailList[7].zhansjqdbfb = this.form.detailList[8].zhansjqdbfb = null;
            this.form.detailList[6].jiegpd = this.form.detailList[7].jiegpd = this.form.detailList[8].jiegpd = null;
          }
        } else {
          this.form.detailList[6].kangwlqdpj = this.form.detailList[7].kangwlqdpj = this.form.detailList[8].kangwlqdpj = null;
          this.form.detailList[6].zhansjqdbfb = this.form.detailList[7].zhansjqdbfb = this.form.detailList[8].zhansjqdbfb = null;
          this.form.detailList[6].jiegpd = this.form.detailList[7].jiegpd = this.form.detailList[8].jiegpd = null;
        }
      } else if (i == 9 || i == 10 || i == 11) {
        if (this.form.detailList[9].kangwlqddz && this.form.detailList[10].kangwlqddz && this.form.detailList[11].kangwlqddz) {
          this.form.detailList[9].kangwlqdpj =
            this.form.detailList[10].kangwlqdpj =
            this.form.detailList[11].kangwlqdpj =
              decimal.divide(decimal.add(decimal.add(this.form.detailList[9].kangwlqddz, this.form.detailList[10].kangwlqddz, 9), this.form.detailList[11].kangwlqddz, 9), 3, 2);
          //占比计算
          if (this.form.shejqddj) {
            this.form.detailList[9].zhansjqdbfb =
              this.form.detailList[10].zhansjqdbfb =
              this.form.detailList[11].zhansjqdbfb =
                decimal.divide(decimal.multiply(100, this.form.detailList[0].kangwlqdpj, 9), this.form.shejqddj, 1);
            //结果判定
            if (parseFloat(this.form.shejqddj) <= parseFloat(this.form.detailList[9].kangwlqdpj)) {
              this.form.detailList[9].jiegpd = this.form.detailList[10].jiegpd = this.form.detailList[11].jiegpd = "符合";
            } else {
              this.form.detailList[9].jiegpd = this.form.detailList[10].jiegpd = this.form.detailList[11].jiegpd = "不符合";
            }
          } else {
            this.form.detailList[9].zhansjqdbfb = this.form.detailList[10].zhansjqdbfb = this.form.detailList[11].zhansjqdbfb = null;
            this.form.detailList[9].jiegpd = this.form.detailList[10].jiegpd = this.form.detailList[1].jiegpd = null;
          }
        } else {
          this.form.detailList[9].kangwlqdpj = this.form.detailList[10].kangwlqdpj = this.form.detailList[11].kangwlqdpj = null;
          this.form.detailList[9].zhansjqdbfb = this.form.detailList[10].zhansjqdbfb = this.form.detailList[11].zhansjqdbfb = null;
          this.form.detailList[9].jiegpd = this.form.detailList[10].jiegpd = this.form.detailList[11].jiegpd = null;
        }
      } else if (i == 12 || i == 13 || i == 14) {
        if (this.form.detailList[12].kangwlqddz && this.form.detailList[13].kangwlqddz && this.form.detailList[14].kangwlqddz) {
          this.form.detailList[12].kangwlqdpj =
            this.form.detailList[13].kangwlqdpj =
            this.form.detailList[14].kangwlqdpj =
              decimal.divide(decimal.add(decimal.add(this.form.detailList[12].kangwlqddz, this.form.detailList[13].kangwlqddz, 9), this.form.detailList[14].kangwlqddz, 9), 3, 2);
          //占比计算
          if (this.form.shejqddj) {
            this.form.detailList[12].zhansjqdbfb =
              this.form.detailList[13].zhansjqdbfb =
              this.form.detailList[14].zhansjqdbfb =
                decimal.divide(decimal.multiply(100, this.form.detailList[12].kangwlqdpj, 9), this.form.shejqddj, 1);
            //结果判定
            if (parseFloat(this.form.shejqddj) <= parseFloat(this.form.detailList[12].kangwlqdpj)) {
              this.form.detailList[12].jiegpd = this.form.detailList[13].jiegpd = this.form.detailList[14].jiegpd = "符合";
            } else {
              this.form.detailList[12].jiegpd = this.form.detailList[13].jiegpd = this.form.detailList[14].jiegpd = "不符合";
            }
          } else {
            this.form.detailList[12].zhansjqdbfb = this.form.detailList[13].zhansjqdbfb = this.form.detailList[14].zhansjqdbfb = null;
            this.form.detailList[12].jiegpd = this.form.detailList[13].jiegpd = this.form.detailList[14].jiegpd = null;
          }
        } else {
          this.form.detailList[12].kangwlqdpj = this.form.detailList[13].kangwlqdpj = this.form.detailList[14].kangwlqdpj = null;
          this.form.detailList[12].zhansjqdbfb = this.form.detailList[13].zhansjqdbfb = this.form.detailList[14].zhansjqdbfb = null;
          this.form.detailList[12].jiegpd = this.form.detailList[13].jiegpd = this.form.detailList[14].jiegpd = null;
        }
      } else if (i == 15 || i == 16 || i == 17) {
        if (this.form.detailList[15].kangwlqddz && this.form.detailList[16].kangwlqddz && this.form.detailList[17].kangwlqddz) {
          this.form.detailList[15].kangwlqdpj =
            this.form.detailList[16].kangwlqdpj =
            this.form.detailList[17].kangwlqdpj =
              decimal.divide(decimal.add(decimal.add(this.form.detailList[15].kangwlqddz, this.form.detailList[16].kangwlqddz, 9), this.form.detailList[17].kangwlqddz, 9), 3, 2);
          //占比计算
          if (this.form.shejqddj) {
            this.form.detailList[15].zhansjqdbfb =
              this.form.detailList[16].zhansjqdbfb =
              this.form.detailList[17].zhansjqdbfb =
                decimal.divide(decimal.multiply(100, this.form.detailList[15].kangwlqdpj, 9), this.form.shejqddj, 1);
            //结果判定
            if (parseFloat(this.form.shejqddj) <= parseFloat(this.form.detailList[15].kangwlqdpj)) {
              this.form.detailList[15].jiegpd = this.form.detailList[16].jiegpd = this.form.detailList[17].jiegpd = "符合";
            } else {
              this.form.detailList[15].jiegpd = this.form.detailList[16].jiegpd = this.form.detailList[17].jiegpd = "不符合";
            }
          } else {
            this.form.detailList[15].zhansjqdbfb = this.form.detailList[16].zhansjqdbfb = this.form.detailList[17].zhansjqdbfb = null;
            this.form.detailList[15].jiegpd = this.form.detailList[16].jiegpd = this.form.detailList[17].jiegpd = null;
          }
        } else {
          this.form.detailList[15].kangwlqdpj = this.form.detailList[16].kangwlqdpj = this.form.detailList[17].kangwlqdpj = null;
          this.form.detailList[15].zhansjqdbfb = this.form.detailList[16].zhansjqdbfb = this.form.detailList[17].zhansjqdbfb = null;
          this.form.detailList[15].jiegpd = this.form.detailList[16].jiegpd = this.form.detailList[17].jiegpd = null;
        }
      }
      Bus.$emit("setSnhntkwlqdList", this.form.detailList);
    },
    //计算强度 1000*hz*jj/宽/高/高
    getkwlqd(hz, area, jj) {
      let a = 150,
        b = 150;
      if (area == "100x100x400") {
        a = b = 100;
      }
      return decimal.divide(decimal.divide(decimal.divide(decimal.multiply(decimal.multiply(1000, hz, 9), jj, 9), a, 9), b, 9), b);
    },
    // 显示检测依据列表
    showBsJiancyjView() {
      this.$refs.bsJiancyjViewRef.init(this.form.jiancyjIds);
    },
    // 检测依据选择
    selectJiancyj(info) {
      // this.$set(this.form, 'jiancyj', info.label);
      this.form.jiancyj = info.label;
      this.form.jiancyjIds = info.ids;
      Bus.$emit("setSnhntkwlBgJiancyj", { jiancyj: this.form.jiancyj, jiancyjIds: this.form.jiancyjIds });
    },
    // 仪器选择
    selectInstrument(info) {
      this.form.zhuyyqsbmcjbh = info.label;
      this.form.shebIds = info.ids;
      Bus.$emit("setSnhntkwlBgZhuyyqsbmcjbh", { zhuyyqsbmcjbh: this.form.zhuyyqsbmcjbh, shebIds: this.form.shebIds });
    },
    // 显示仪器列表
    showBsInstrumentView() {
      this.$refs.bsInstrumentViewRef.init(this.form.shebIds);
    },

    // 显示判定依据列表
    showBsJudgeBaseView() {
      this.$refs.bsJudgeBaseViewRef.init(this.form.pandyjIds);
    },
    // 判断依据选择
    selectJudge(info) {
      if (!info || !info.label) {
        return;
      }
      if (!this.form.pandyj) {
        this.form.pandyj = info.label;
      } else {
        if (info && info.label) {
          this.form.pandyj += "、" + info.label;
        }
      }
      // 添加指标 info.list
      let keys = [];
      info.list.forEach((item) => {
        if (this.form.baDetailVos[item.refQualId] && this.form.baDetailVos[item.refQualId].jiancjg) {
          this.form.baDetailVos[item.refQualId].symbolValue = item.symbolValue;
          this.form.baDetailVos[item.refQualId].num1 = item.num1;
          this.form.baDetailVos[item.refQualId].num2 = item.num2;
          keys.push(item.refQualId);
        }
      });
      this.computeDetectionResult(keys);
    },
    // 计算检测结果
    computeDetectionResult(keys) {
      if (!keys || keys.length <= 0) {
        return;
      }
      const data = keys.map((key) => {
        const info = {
          ...this.form.baDetailVos[key],
          jiancjg: this.form.baDetailVos[key].jiancjg == "-" ? "" : this.form.baDetailVos[key].jiancjg
        };
        return info;
      });
      computeBiQualification(data).then((res) => {
        const returnData = res.data;
        returnData.forEach((item) => {
          if (!item.symbolValue && !item.num1 && !item.num2) {
            item.jiszb = "-";
          }
          item.jiancjg = item.jiancjg ? item.jiancjg : "-";
          this.form.baDetailVos[item.qualId] = item;
        });
      });
    },
    // 获取检测结论
    getJcjl() {
      const form = JSON.parse(JSON.stringify(this.form));
      queryJcjl(emptyConvert(form)).then((res) => {
        const info = res.data;
        this.form.jiancjl = info.jiancjl;
      });
    },
    // 编辑单个技术指标后赋值
    selectJudgeBaseEdit(info) {
      if (info.qualId) {
        this.form.baDetailVos[info.qualId] = info;
      }
      this.computeDetectionResult([info.qualId]);
    },

    //制件日期改变
    changesyrq(item) {
      //计算试验日期；
      if (item.zhizrq && item.lingq) {
        let syrq = new Date(item.zhizrq);
        syrq.setDate(syrq.getDate() + parseInt(item.lingq));
        let year = syrq.getFullYear();
        let month = syrq.getMonth() + 1; // 获取月份，需要+1因为从0开始计数
        let day = syrq.getDate(); // 获取日
        item.shiyrq = `${year}-${month.toString().padStart(2, "0")}-${day.toString().padStart(2, "0")}`;
      } else {
        item.shiyrq = undefined;
      }
      Bus.$emit("setSnhntkwlqdList", this.form.detailList);
    },
    handleshijbh(i, e) {
      e.shijbh = Math.ceil(i / 3).toString() + "-" + (i % 3 == 0 ? 3 : i % 3).toString();
      return e.shijbh;
    },
    handleFocus(event) {
      handleFocus(event, this.page, this.form[event]);
    },
    handleKeyDown(event, rowIndex, colIndex) {
      const maxArr = [1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
      // const maxArr = [1, 2, 2, 2];
      const ref = handleKeyDown(event, rowIndex, colIndex, maxArr);
      if (this.$refs[ref]?.length) {
        this.$refs[ref][0].focus();
      } else if (this.$refs[ref]) {
        this.$refs[ref].focus();
      }
    }
  }
};
</script>

<style scoped lang="scss">
</style>
